<template>
    <el-form :model="eStationForm" status-icon :rules="rules" ref="eStationForm"
             label-width="150px"
             style="margin-top: 10px;color: #1f2d3d">
        <el-form-item class="form-label" label="变电站编码" prop="cid">
            <el-col :span="19">
                <el-input v-model="eStationForm.cid" placeholder="变电站编码"
                          maxlength="11" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="变电站名称" prop="name">
            <el-col :span="19">
                <el-input v-model="eStationForm.name" placeholder="变电站名称"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="变电站位置" prop="position">
            <el-col :span="19">
                <el-input v-model="eStationForm.position" placeholder="变电站位置"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="经度" prop="longitude">
            <el-col :span="19">
                <el-input v-model="eStationForm.longitude" placeholder="经度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="纬度" prop="latitude">
            <el-col :span="19">
                <el-input v-model="eStationForm.latitude" placeholder="纬度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="变电站类型" prop="typeSubstation">
            <el-col :span="19">
                <el-input v-model="eStationForm.typeSubstation" placeholder="变电站类型"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="变电站电压等级" prop="voltageGrade">
            <el-col :span="19">
                <el-input v-model="eStationForm.voltageGrade" placeholder="变电站电压等级"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="房屋建筑结构类型" prop="structureType">
            <el-col :span="19">
                <el-input v-model="eStationForm.structureType" placeholder="房屋建筑结构类型"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="建设年代" prop="year">
            <el-col :span="19">
                <el-input v-model="eStationForm.year" placeholder="建设年代"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="设防烈度" prop="intensity">
            <el-col :span="19">
                <el-input v-model="eStationForm.intensity" placeholder="设防烈度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="变电站总造价" prop="substationTotalCost">
            <el-col :span="19">
                <el-input v-model="eStationForm.substationTotalCost" placeholder="变电站总造价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="室外高压电气设备总造价" prop="outdoorHighVoltageApplianceCost">
            <el-col :span="19">
                <el-input v-model="eStationForm.outdoorHighVoltageApplianceCost" placeholder="室外高压电气设备总造价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="房屋建筑总造价" prop="costBuilding">
            <el-col :span="19">
                <el-input v-model="eStationForm.costBuilding" placeholder="房屋建筑总造价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="室内设备总造价" prop="indoorEquipmentCost">
            <el-col :span="19">
                <el-input v-model="eStationForm.indoorEquipmentCost" placeholder="室内设备总造价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="场地类别" prop="site">
            <el-col :span="19">
                <el-input v-model="eStationForm.site" placeholder="场地类别"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="关联子任务" prop="sid" style="display: none">
            <el-input v-model="eStationForm.sid"
                      maxlength="20" autocomplete="off"/>
        </el-form-item>
    </el-form>
</template>

<script>
    import qs from 'qs';

    export default {
        name: "NewElectricityStation",
        data() {
            return {
                eStationForm: {
                    id: '',
                    cid: '',
                    name: '',
                    position: '',
                    longitude: '',
                    latitude: '',
                    typeSubstation: '',
                    voltageGrade: '',
                    structureType: '',
                    year: '',
                    intensity: '',
                    substationTotalCost: '',
                    outdoorHighVoltageApplianceCost: '',
                    costBuilding: '',
                    indoorEquipmentCost: '',
                    site: '',
                    sid: ''
                },
                rules: {
                    cid: [],
                    name: [],
                    position: [],
                    longitude: [],
                    latitude: [],
                    typeSubstation: [],
                    voltageGrade: [],
                    structureType: [],
                    year: [],
                    intensity: [],
                    substationTotalCost: [],
                    outdoorHighVoltageApplianceCost: [],
                    costBuilding: [],
                    indoorEquipmentCost: [],
                    site: []
                }
            }
        },
        mounted() {
            if (this.id !== -1) {
                axios.post("/bjdzms/electricityChangeStation/findById",
                    qs.stringify({
                        'id': this.id
                    })).then(res => {
                    this.eStationForm = res.data.datas;
                });
            }
        },
       props: {
            sid: {
                type: Number,
                default: -1
            },
            id: {
                type: Number,
                default: -1
            }
        },
        methods: {
            to(path) {
                this.$router.push({name: path});
            },
            submitForm() {
                if (this.id !== -1) {
                    this.eStationForm.id = this.id;
                    axios.post("/bjdzms/electricityChangeStation/upd",
                        qs.stringify(this.eStationForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                } else {
                    this.eStationForm.sid = this.sid;
                    axios.post("/bjdzms/electricityChangeStation/add",
                        qs.stringify(this.eStationForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                }
            }
        }
    }
</script>

<style>
    .el-upload-dragger {
        height: 40px !important;
    }
</style>

<style scoped>
    .el-header {
        background: #EBEBEB;
        color: #e5e9ef;
        font-size: 2em;
        line-height: 80px;
        border: 5px solid #EBEBEB;
    }

    .el-main {
        background: #fff;
    }

    .el-container {
        height: 100%;
    }

    .el-form-item {
        width: 610px;
    }
</style>
